<?php

class ClearController extends Zend_Controller_Action
{

    public function init()
    {
        Zend_Registry::get('layout')->setLayout('duty');
        
        $activeResource=Application_Model_Cache::RESOURCE_NAME;
        
        // seting active resource
        Zend_Registry::set('resource',$activeResource);

        $this->_flashMessenger = $this->_helper->getHelper('FlashMessenger');
        $this->view->flash_messages = $this->_flashMessenger->getMessages();
    }

    public function indexAction()
    {
        if (!Zend_Registry::get('user')->canManage())
        {
            return $this->_response->setRedirect(Zend_Registry::get('view')->fixUrl());
        }
        
        $cache=Zend_Registry::get('cache');
        
        $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
        
        $this->_helper->FlashMessenger(Zend_Registry::get('locale')->_('Cache cleared'));
            
        return $this->_response->setRedirect(Zend_Registry::get('view')->fixUrl());
    }


}

